-- @owner: @haomeng802
-- @date: 2023/1/4
-- @testpoint: connect by子句,省略prior关键字,部分测试点合理报错


--step1:创建普通表，插入数据;expect:建表成功，插入数据成功
drop table if exists t_connectby_013 cascade;
create table t_connectby_013(name varchar, id int, fatherid int);
insert into t_connectby_013 values('A', 1, 0), ('B', 2, 1),('C',3,1),('D',4,1),('E',5,2);

--step2:省略prior关键字，进行递归查询;expect:成功
select * from t_connectby_013 connect by id = fatherid;

--step3:省略prior关键字，含start with子句，进行递归查询;expect:合理报错，至少含一个递归键
select * from t_connectby_013 start with fatherid=1 connect by nocycle id = fatherid;

--step4:省略prior关键字，结合层次递归查询函数查看递归层级;expect:成功
select sys_connect_by_path(name,'-') as path, *, level from t_connectby_013 connect by id = fatherid;

--step5:清理环境;expect:成功
drop table t_connectby_013 cascade;
